package cn.pupil.springframework.context.support;

import cn.pupil.springframework.beans.factory.BeanFactory;
import cn.pupil.springframework.context.ApplicationEvent;
import cn.pupil.springframework.context.ApplicationListener;
import cn.pupil.springframework.context.event.AbstractApplicationEventMulticaster;

/**
 * @Description: 应用事件广播器简单实现类
 * @Author: pupil
 * @Date: 2024/11/13 下午 4:50
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    @SuppressWarnings("unchecked")
    @Override
    public void multicastEvent(final ApplicationEvent event) {
        for (final ApplicationListener listener : getApplicationListeners(event)) {
            listener.onApplicationEvent(event);
        }
    }
}
